﻿
@using Webdiyer.WebControls.Mvc;
@model Webdiyer.WebControls.Mvc.PagedList<XQ.SP.Model.UserInfoItem>
@{
    ViewBag.Title = "用户数据权限 信息列表";
    ViewBag.TextName = "用户数据权限 信息列表";
    Layout = "~/Views/Shared/Admin.cshtml";
}
<link rel="stylesheet" type="text/css" href="/Res/CSS/css/base.css" />
<link rel="stylesheet" type="text/css" href="/Res/CSS/css/styles.css" />
<div class="breadcrumb">
    <a href="javascript:void(0);">用户数据权限 信息列表</a>
</div>
<div class="pd15">
<div class="calc-box">
    <div class="filter">
        <form id="frmUpload" action="/UserInfo/UploadUsers/" method="post" onsubmit="return toVaild()" enctype="multipart/form-data" style="display:inline-block;">
            上传用户：
            <input type="file" name="file" id="file" />
            <input type="submit" class="btn" style="margin-left: 5px; border: 0; width: 70px; height: 26px;" value="上传" />
        </form>
        <form action="/UserInfo/List/" method="post" onsubmit="return searchCheck(this);" style="margin-left:50px;display:inline-block;">
            类别：
			@Html.DropDownList("search_type", (IEnumerable<SelectListItem>)ViewBag.ListSeachType)
            &nbsp;
            名称：
			<input type="text" placeholder="@ViewBag.ListSeachValue" id="search_input" name="search_input" value="@ViewBag.tapStr" class="w200" />
            <button type="submit" class="btn">查询</button>
        </form>
    </div>
		<div class="operation bd-t pd-t10 pd-b10 mg-t10">
			<div class="fl">
				<a href="/UserInfo/Edit" class="btn btn-danger"><i class="iconfont">&#xe64d;</i>添加</a>
            <a href="javascript:void(0);" onclick="swapCheck()" class="btn btn-danger">全选</a>
            <a href="javascript:void(0);" onclick="Getcheckbox()" class="btn btn-danger"><i class="iconfont">&#xe600;</i>删除</a>
			</div>
		</div>
</div>

<table cellpadding="0" cellspacing="0" width="100%"class="pub-table pub-table-hover"  >
@*<table cellpadding="0" cellspacing="0" width="1500px;"class="pub-table pub-table-hover" style="display:block; overflow: auto; " >*@
    <tr>
        <th style="width:30px">序号</th>
        <th style="width:30px">删除</th>
        
                        <th>用户 名</th>
                        <th>密码</th>
                        <th>县市</th>
                        <th>乡镇</th>
                        <th>村名称</th>
        <th>操作</th>
    </tr>
    @{
        int tCount=0;
        foreach (var item in Model)
        {
        tCount++;
        <tr>
            <td align="center">@tCount</td>
                <td align="center">
                    <div class="check-box check-box-one">
                        <input type="checkbox" id="checkedId_ @item.Id" name="checkId" value="@item.Id" />
                        <label for="checkedId_ @item.Id">
                            <span><i class="iconfont">&#xe654;</i></span>
                        </label>
                    </div>
                </td>
            
                        <td align="center">@item.UserName</td>
                        <td align="center">@item.Pwd</td>
                        <td align="center">@item.City</td>
                        <td align="center">@item.Towns</td>
                        <td align="center">@item.Village</td>
            <td align="center"><a href="/UserInfo/Edit?id=@item.Id">编辑</a>&nbsp;&nbsp;<a href="javascript:void(0);" onclick="DelId(@item.Id)">删除</a></td>
        </tr>
        }
    }
</table>
    </div>
    <div class="pages">
        @Html.Pager(Model, new PagerOptions { PageIndexParameterName = "pageIndex", NumericPagerItemWrapperFormatString = "<span class=\"cpb\">{0}</span>" }, null, null, null)
    </div>


<script type="text/javascript" src="/Res/CSS/js/jquery.js"></script>
<script type="text/javascript" src="/Res/CSS/js/jquery-form.js"></script>
<script type="text/javascript">
    $(function () {
        $('#frmUpload').ajaxForm(function (data) {
            top.hideLoading();
            if (data.result.status) {
                alert("上传数据成功，请刷新数据！");
            } else {
                alert("上传数据失败！");
            }
        })
    })
    function toVaild() {
        top.showLoading();
        return true;
    }

    var isCheckAll = false;
    function swapCheck() {
        if (isCheckAll) {
            $("input[type='checkbox']").each(function () {
                this.checked = false;
            });
            isCheckAll = false;
        } else {
            $("input[type='checkbox']").each(function () {
                this.checked = true;
            });
            isCheckAll = true;
        }
    }
    function Getcheckbox() {
        var str = document.getElementsByName("checkId");
        var objarray = str.length;
        var chestr = "";
        for (i = 0; i < objarray; i++) {
            if (str[i].checked == true) {
                chestr += str[i].value + ",";
            }
        }
        chestr = chestr.substr(0, chestr.length - 1);
        if (chestr.length <= 0) {
            alert("请选择要删除的选项");
        }
        DelId(chestr);
    }
    function DelId(ids) {
        if (!confirm('您确定删除吗?')) {
            return;
        }
        $.ajax({
            type: 'POST',
            url: '/UserInfo/Deletes?ids=' + ids + "&uid=@UsersInfo.GetUsersID()",
            data: { ids: ids },
            dataType: "json",
            success: function (msg) {
                if (msg == "false") {
                    alert("删除信息错误，删除失败！");
                }
                else {
                    alert("删除成功");
                    window.location = "/UserInfo/List?pageIndex=@ViewBag.pageIndex";
                }
            }
        });
    }
</script>

